//
//  NavigateViewController.m
//  YTwallet
//
//  Created by hadrlog on 2019/2/22.
//  Copyright © 2019年 hadrlog. All rights reserved.
//

#import "NavigateViewController.h"
#import "micros.h"
@interface NavigateViewController ()<UIGestureRecognizerDelegate>

@end

@implementation NavigateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
    self.navigationBar.translucent = YES;
    self.interactivePopGestureRecognizer.delegate = self;
    
    //修改导航栏title颜色、字体
    [self.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17],NSForegroundColorAttributeName:[UIColor blackColor]}];
}

//重写返回按钮
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    NSString *ctrlName = NSStringFromClass([viewController class]);
    
    if ([ctrlName isEqualToString:@"HomeViewController"] ||[ctrlName isEqualToString:@"ShareViewController"]||[ctrlName isEqualToString:@"MineViewController"]) {
        
        viewController.hidesBottomBarWhenPushed = NO;
        
    }else{
        
        viewController.hidesBottomBarWhenPushed = YES;
    }
    
    [super pushViewController:viewController animated:animated];
    
    if (self.viewControllers.count != 1) {
        viewController.navigationItem.leftBarButtonItem = [self creatBackButton];
    }
    
}

-(UIBarButtonItem *)creatBackButton
{
    return [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"nav_ic_arrow_left_black"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]style:UIBarButtonItemStylePlain target:self action:@selector(popSelf)];
    
}
-(void)popSelf
{
    [self popViewControllerAnimated:YES];
}

//滑动返回代理方法
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    if (self.viewControllers.count == 1) {
        return NO;
    }
    else if(self.navigationBar.hidden == YES)
    {
        return NO;
    }
    else
    {
        return YES;
    }
}



-(void)backAction
{
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
    
}


@end
